{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "_macros.html" as macros %}
{% import "user/partial/search_training_user_form.html" as search_user_form_macro %}
{% import "user/partial/training_user_table.html" as user_table_macro %}

{% block title %}万屏时代OPC--养成用户{% endblock %}

{% block panel_heading %}
  万屏时代OPC--养成用户
{% endblock %}

{% block panel_body %}
    {{ search_user_form_macro.gen_form(form) }}

    {% if pagination %}
    <div class="pagination">
        {{ macros.pagination_widget(pagination, 'op_bp.training_user_list', **url_kwargs) }}
    </div>
    {% endif %}

    {{ user_table_macro.gen_table(users) }}

    {% if pagination %}
    <div class="pagination">
        {{ macros.pagination_widget(pagination, 'op_bp.training_user_list', **url_kwargs) }}
    </div>
    {% endif %}

    <div class="modal fade" id="user_add_tag_modal" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                  <h4 class="modal-title" id="myModalLabel">用户打标签</h4>
              </div>
              <div class="modal-body">
                  <form action="" method="post" class="form" id="user_add_tag_form">
                      <div class="form-group">
                          <div class="row">
                              <label class="control-label  col-xs-3 col-xs-offset-1" for="reason">手机号:</label>
                              <div class="col-xs-7">
                                  <input type="text" class="form-control" disabled id="tag_user_mobile">
                              </div>
                          </div>
                          <br>
                          <div class="row">
                              <label class="control-label  col-xs-3 col-xs-offset-1" for="reason">昵称:</label>
                              <div class="col-xs-7">
                                  <input type="text" class="form-control" disabled id="tag_user_nickname">
                              </div>
                          </div>
                          <br>
                          <div class="row user_tag_div">
                              <label class="control-label  col-xs-3 col-xs-offset-1" for="reason">标签:</label>
                              <input type="checkbox" name="tag_phone_contact" id="tag_user_phone_contact"> 已电话联系
                              <input type="checkbox" name="tag_add_wechat" id="tag_user_add_wechat"> 已加微信
                          </div>
                      </div>
                      <div class="form-group">
                          <div class="col-xs-offset-4">
                              <input type="submit" class="btn btn-danger" value="提交">
                          </div>
                      </div>
                  </form>
              </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block scripts %}
{{ super() }}
    <script>
        $(document).ready( function () {
            $('.user_add_tag').click(function(){
                $('#tag_user_mobile').val($(this).data('user-mobile'));
                $('#tag_user_nickname').val($(this).data('user-nickname'));

                $('#user_add_tag_form').prop('action', "/op/user_training_add_tags/" + $(this).data('user-id'));
                if($(this).data('tag_add_wechat') == 'True'){
                    $('#tag_user_add_wechat').prop('checked', true)
                }
                if($(this).data('tag_phone_contact') == 'True'){
                    $('#tag_user_phone_contact').prop('checked', true)
                }
                $('#user_add_tag_modal').modal()
            });
        })
    </script>
{% endblock %}